﻿using System;
using System.Windows.Controls;

namespace Hx.Components
{
    public partial class Center
    {
        public Action<StackPanel> OnInitArticles;
        public Action<StackPanel> OnInitQuotes;
        public Action<StackPanel> OnInitLinks;

        public Center()
        {
            InitializeComponent();

            InitArticles();
            InitQuotes();
            InitLinks();
        }

        private void InitArticles()
        {
            if (OnInitArticles != null)
                OnInitArticles(AllArticles);

            //WebApiHelper.GetResponseModel<PagedResult<ArticleModel>>(String.Format(UrlDefinition.GetAllArticles, 1),
            //    null,
            //    articles =>
            //    {
            //        foreach (var article in articles.DataSource)
            //            AllArticles.Children.Add(new ArticleRow(article));
            //    });
        }

        private void InitQuotes()
        {
            if (OnInitQuotes != null)
                OnInitQuotes(AllQuotes);

            //WebApiHelper.GetResponseModel<PagedResult<QuoteModel>>(String.Format(UrlDefinition.GetAllQuote, 1),
            //    null,
            //    quotes =>
            //    {
            //        foreach (var quote in quotes.DataSource)
            //            AllQuotes.Children.Add(new QuoteRow(quote));
            //    });
        }

        private void InitLinks()
        {
            if (OnInitLinks != null)
                OnInitLinks(AllLinks);

            //WebApiHelper.GetResponseModel<PagedResult<LinkModel>>(String.Format(UrlDefinition.GetAllLinks, 1),
            //   null,
            //   links =>
            //   {
            //       foreach (var link in links.DataSource)
            //           AllLinks.Children.Add(new LinkRow(link));
            //   });
        }
    }
}